{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import tensorflow as tf\n",
    "import os\n",
    "import time\n",
    "import argparse\n",
    "import datetime\n",
    "\n",
    "from SE_model_multi_attn import *\n",
    "from process_data_multi import *\n",
    "from evaluation_multi import *\n",
    "from project_config import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "load data : train_audio_mfcc.npy train_seqN.npy train_audio_prosody.npy train_nlp_trans.npy train_label.npy\n",
      "[completed] load data\n",
      "load data : dev_audio_mfcc.npy dev_seqN.npy dev_audio_prosody.npy dev_nlp_trans.npy dev_label.npy\n",
      "[completed] load data\n",
      "load data : test_audio_mfcc.npy test_seqN.npy test_audio_prosody.npy test_nlp_trans.npy test_label.npy\n",
      "[completed] load data\n",
      "[launch-multi] create audio model\n",
      "[launch-audio] placeholders\n",
      "WARNING:tensorflow:From SE_model_audio.py:51: The name tf.placeholder is deprecated. Please use tf.compat.v1.placeholder instead.\n",
      "\n",
      "[launch-audio] create gru cell\n",
      "WARNING:tensorflow:From SE_model_audio.py:78: The name tf.variable_scope is deprecated. Please use tf.compat.v1.variable_scope instead.\n",
      "\n",
      "WARNING:tensorflow:From SE_model_audio.py:59: __init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "This class is equivalent as tf.keras.layers.GRUCell, and will be replaced by that in Tensorflow 2.0.\n",
      "WARNING:tensorflow:From SE_model_audio.py:80: __init__ (from tensorflow.python.ops.rnn_cell_impl) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "This class is equivalent as tf.keras.layers.StackedRNNCells, and will be replaced by that in Tensorflow 2.0.\n",
      "WARNING:tensorflow:From SE_model_audio.py:87: dynamic_rnn (from tensorflow.python.ops.rnn) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Please use `keras.layers.RNN(cell)`, which is equivalent to this API\n",
      "WARNING:tensorflow:Entity <bound method MultiRNNCell.call of <tensorflow.python.ops.rnn_cell_impl.MultiRNNCell object at 0x7f4ba0265290>> could not be transformed and will be executed as-is. Please report this to the AutgoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: converting <bound method MultiRNNCell.call of <tensorflow.python.ops.rnn_cell_impl.MultiRNNCell object at 0x7f4ba0265290>>: AttributeError: 'module' object has no attribute 'Num'\n",
      "WARNING: Entity <bound method MultiRNNCell.call of <tensorflow.python.ops.rnn_cell_impl.MultiRNNCell object at 0x7f4ba0265290>> could not be transformed and will be executed as-is. Please report this to the AutgoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: converting <bound method MultiRNNCell.call of <tensorflow.python.ops.rnn_cell_impl.MultiRNNCell object at 0x7f4ba0265290>>: AttributeError: 'module' object has no attribute 'Num'\n",
      "WARNING:tensorflow:From /home/dato/anaconda2/envs/tf114_p27/lib/python2.7/site-packages/tensorflow/python/ops/rnn_cell_impl.py:564: calling __init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Call initializer instance with the dtype argument instead of passing it to the constructor\n",
      "WARNING:tensorflow:From /home/dato/anaconda2/envs/tf114_p27/lib/python2.7/site-packages/tensorflow/python/ops/rnn_cell_impl.py:574: calling __init__ (from tensorflow.python.ops.init_ops) with dtype is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Call initializer instance with the dtype argument instead of passing it to the constructor\n",
      "WARNING:tensorflow:Entity <bound method GRUCell.call of <tensorflow.python.ops.rnn_cell_impl.GRUCell object at 0x7f4ba0265050>> could not be transformed and will be executed as-is. Please report this to the AutgoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: converting <bound method GRUCell.call of <tensorflow.python.ops.rnn_cell_impl.GRUCell object at 0x7f4ba0265050>>: AssertionError: Bad argument number for Name: 3, expecting 4\n",
      "WARNING: Entity <bound method GRUCell.call of <tensorflow.python.ops.rnn_cell_impl.GRUCell object at 0x7f4ba0265050>> could not be transformed and will be executed as-is. Please report this to the AutgoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: converting <bound method GRUCell.call of <tensorflow.python.ops.rnn_cell_impl.GRUCell object at 0x7f4ba0265050>>: AssertionError: Bad argument number for Name: 3, expecting 4\n",
      "WARNING:tensorflow:From /home/dato/anaconda2/envs/tf114_p27/lib/python2.7/site-packages/tensorflow/python/ops/rnn.py:244: where (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.\n",
      "Instructions for updating:\n",
      "Use tf.where in 2.0, which has the same broadcast rule as np.where\n",
      "[launch-audio] add prosody feature, dim: 35\n",
      "[launch-multi] create text model\n",
      "[launch-text] placeholders\n",
      "[launch-text] create embedding\n",
      "WARNING:tensorflow:From SE_model_text.py:72: The name tf.random_normal is deprecated. Please use tf.random.normal instead.\n",
      "\n",
      "[launch-text] create gru cell\n",
      "WARNING:tensorflow:Entity <bound method MultiRNNCell.call of <tensorflow.python.ops.rnn_cell_impl.MultiRNNCell object at 0x7f4ba0265250>> could not be transformed and will be executed as-is. Please report this to the AutgoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: converting <bound method MultiRNNCell.call of <tensorflow.python.ops.rnn_cell_impl.MultiRNNCell object at 0x7f4ba0265250>>: AttributeError: 'module' object has no attribute 'Num'\n",
      "WARNING: Entity <bound method MultiRNNCell.call of <tensorflow.python.ops.rnn_cell_impl.MultiRNNCell object at 0x7f4ba0265250>> could not be transformed and will be executed as-is. Please report this to the AutgoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: converting <bound method MultiRNNCell.call of <tensorflow.python.ops.rnn_cell_impl.MultiRNNCell object at 0x7f4ba0265250>>: AttributeError: 'module' object has no attribute 'Num'\n",
      "WARNING:tensorflow:Entity <bound method GRUCell.call of <tensorflow.python.ops.rnn_cell_impl.GRUCell object at 0x7f4ba02654d0>> could not be transformed and will be executed as-is. Please report this to the AutgoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: converting <bound method GRUCell.call of <tensorflow.python.ops.rnn_cell_impl.GRUCell object at 0x7f4ba02654d0>>: AssertionError: Bad argument number for Name: 3, expecting 4\n",
      "WARNING: Entity <bound method GRUCell.call of <tensorflow.python.ops.rnn_cell_impl.GRUCell object at 0x7f4ba02654d0>> could not be transformed and will be executed as-is. Please report this to the AutgoGraph team. When filing the bug, set the verbosity to 10 (on Linux, `export AUTOGRAPH_VERBOSITY=10`) and attach the full output. Cause: converting <bound method GRUCell.call of <tensorflow.python.ops.rnn_cell_impl.GRUCell object at 0x7f4ba02654d0>>: AssertionError: Bad argument number for Name: 3, expecting 4\n",
      "[launch-multi] placeholders\n",
      "[launch-multi] create attention module\n",
      "WARNING:tensorflow:From SE_model_multi_attn.py:144: The name tf.random_uniform is deprecated. Please use tf.random.uniform instead.\n",
      "\n",
      "[launch-multi] create output projection layer from (text_final_dim(==audio) + text_final_dim)\n",
      "[launch-multi] create optimizer\n",
      "WARNING:tensorflow:From SE_model_multi_attn.py:201: The name tf.train.AdamOptimizer is deprecated. Please use tf.compat.v1.train.AdamOptimizer instead.\n",
      "\n",
      "[launch-multi] create summary\n",
      "WARNING:tensorflow:From SE_model_multi_attn.py:211: The name tf.summary.scalar is deprecated. Please use tf.compat.v1.summary.scalar instead.\n",
      "\n",
      "WARNING:tensorflow:From SE_model_multi_attn.py:212: The name tf.summary.merge_all is deprecated. Please use tf.compat.v1.summary.merge_all instead.\n",
      "\n"
     ]
    }
   ],
   "source": [
    "batch_gen = ProcessDataMulti('../data/target/audio_woZ_set01/')\n",
    "\n",
    "model = SingleEncoderModelMultiAttn(\n",
    "                                    batch_size = 2,\n",
    "                                    lr = 0.001,\n",
    "                                    encoder_size_audio = 10,\n",
    "                                    num_layer_audio = 1,\n",
    "                                    hidden_dim_audio = 10,                \n",
    "                                    dr_audio = 1.0,\n",
    "                                    encoder_size_text = 5,\n",
    "                                    num_layer_text = 1,\n",
    "                                    hidden_dim_text = 5,                \n",
    "                                    dr_text = 1.0,\n",
    "                                    dic_size = batch_gen.dic_size,\n",
    "                                    use_glove = False\n",
    "                                    )\n",
    "model.build_graph()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "config = tf.ConfigProto()\n",
    "config.gpu_options.allow_growth = True\n",
    "sess = tf.Session(config=config)\n",
    "sess.run(tf.global_variables_initializer())"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "[array([1672,  621,    0,    0,    0]), array([1385,  787, 1879, 3558,  667])]\n",
      "[2, 5]\n"
     ]
    }
   ],
   "source": [
    "raw_encoder_inputs_audio, raw_encoder_seq_audio, raw_encoder_prosody, raw_encoder_inputs_text, raw_encoder_seq_text, raw_label = batch_gen.get_batch(\n",
    "                        batch_size=model.batch_size,\n",
    "                        data=batch_gen.train_set,\n",
    "                        encoder_size_audio=model.encoder_size_audio,\n",
    "                        encoder_size_text=model.encoder_size_text,\n",
    "                        is_test=False\n",
    "                        )\n",
    "\n",
    "# prepare data which will be push from pc to placeholder\n",
    "input_feed = {}\n",
    "\n",
    "input_feed[model.encoder_inputs_audio] = raw_encoder_inputs_audio\n",
    "input_feed[model.encoder_seq_audio] = raw_encoder_seq_audio\n",
    "input_feed[model.encoder_prosody] = raw_encoder_prosody\n",
    "input_feed[model.dr_prob_audio] = model.dr_audio\n",
    "\n",
    "input_feed[model.encoder_inputs_text] = raw_encoder_inputs_text\n",
    "input_feed[model.encoder_seq_text] = raw_encoder_seq_text\n",
    "input_feed[model.dr_prob_text] = model.dr_text\n",
    "\n",
    "input_feed[model.y_labels] = raw_label\n",
    "\n",
    "print(raw_encoder_inputs_text)\n",
    "print(raw_encoder_seq_text)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "r1, r2 = sess.run([model.tmp_norm,\n",
    "                   model.tmp_norm],\n",
    "                  input_feed)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[0.42401603, 0.57598394, 0.        , 0.        , 0.        ],\n",
       "       [0.16723073, 0.22598384, 0.21686387, 0.21327227, 0.17664926]],\n",
       "      dtype=float32)"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "r1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python [conda env:tf114_p27]",
   "language": "python",
   "name": "conda-env-tf114_p27-py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
